<?php
    // estilos -- ver por qué no puedo usar class con un css - otra clase debe estar bloqueandolo
    $tabla_orga_td = 'vertical-align: middle; background-color: transparent; border: 1px;';    

    // imagenes
    $prev_img = $this->Html->image("restaurante/ic_navegar_left.png", array("width" => "32px", "height" => "32px", "id" => "nav_icon_left"));    
    $next_img = $this->Html->image("restaurante/ic_navegar.png", array("width" => "32px", "height" => "32px", "id" => "nav_icon_right"));    
    $prev_img_disabled = $this->Html->image("restaurante/ic_nav_left_disabled.png", array("width" => "32px", "height" => "32px", "id" => "nav_icon_left_disabled"));    
    $next_img_disabled = $this->Html->image("restaurante/ic_navegar_disabled.png", array("width" => "32px", "height" => "32px", "id" => "nav_icon_right_disabled"));    


    $volver_img = $this->Html->image("restaurante/ic_back.png", array("id" => "back_icon"));    
    $nuevo_img = $this->Html->image("restaurante/ic_add.png", array("id" => "add_icon"));    
    $cancel_img = $this->Html->image("restaurante/ic_cancel.png", array("id" => "back_icon"));    
    $save_img = $this->Html->image("restaurante/ic_ok.png", array("id" => "save_icon"));    
    
    $editar_img = $this->Html->image("restaurante/doc_images.png", array("width" => "24px", "height" => "24px"));    
    
?>

<?php $options = array(1 => 'Guarnición', 2 => 'Salsa'); ?>    

<!--- MARCO DE LA PANTALLA ------>
<table><tr><td style="padding: 20px; background: white; border: none;">
           
<table>
    <tr style="border: 2px;">
        <td style="width: 15%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo $this->Html->image("restaurante/ic_resto.png", array("width" => "64px", "height" => "64px", "id" => "resto_icon"));?></td>
        <td style="width: 55%; text-align:left; <?php echo $tabla_orga_td;?>"><h1 class="titulo_ventana">AGREGADOS</h1></td>
        <td style="width: 30%; text-align:right; <?php echo $tabla_orga_td;?>">
            <table>
                <tr><td style="text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Usuario: '.$nombre_usuario;?></td></tr>
                <tr><td style="text-align:right; <?php echo $tabla_orga_td;?>"><?php echo $this->Html->link('Cerrar sesión', array("controller"=>"users", "action"=>"logout"), array('title' => 'Cerrar sesión', 'escape' => false));?></td></tr>
            </table>
        </td>
    </tr>      
</table>
<hr>

<!--- CONTROLES Y BOTONERA FILTROS ------>

<?php echo $this->Form->create('Agregado', array('action'=>'/index','novalidate' => true)); ?>
<table>
    <tr>
        <td style="width: 15%;<?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('filtro_codigo', array('label' => 'Código')); ?></td>
        <td style="width: 25%;<?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('filtro_descripcion', array('label' => 'Descripción')); ?></td>
        <td style="width: 15%;<?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('filtro_guarni', array('checked' => true,'label' => 'Guarniciones')); ?></td>
        <td style="width: 15%;<?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('filtro_salsa', array('checked' => true,'label' => 'Salsas')); ?></td>
        <td style="width: 15%;<?php echo $tabla_orga_td;?>"><?php echo $this->Form->input('filtro_activo', array('checked' => true,'label' => 'Activos')); ?></td>
        <td style="width: 2%; <?php echo $tabla_orga_td;?>"></td>
        <td style="width: 7%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Buscar'; ?></td>
        <td style="width: 7%; text-align:left; <?php echo $tabla_orga_td;?>"><?php echo $this->Form->submit('restaurante/ic_search.png',array('class' => 'boton-buscar')); ?> </td>
        <td style="width: 7%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Limpiar'; ?></td>
        <td style="width: 7%; text-align:left; <?php echo $tabla_orga_td;?>"><?php echo $this->Form->button('', array('type'=>'reset','class' => 'boton-limpiar')); ?></td>   
    </tr>
</table>
<?php echo $this->Form->end(); ?>

<!--- GRILLA ------>
<table>
    <tr>
        <th style="width: 20%;"><?php echo $this->Paginator->sort('Agregado.codigo','Código',array('direction' => 'asc') ); ?></th>
        <th style="width: 40%;"><?php echo $this->Paginator->sort('Agregado.descripcion','Descripción',array('direction' => 'asc') ); ?></th>
        <th style="width: 10%; text-align:center;"><?php echo "Tipo"; ?></th>
        <th style="width: 10%; text-align:center;"><?php echo "Hay Stock"; ?></th>
        <th style="width: 10%; text-align:center;"><?php echo "Activo"; ?></th>
        <th style="width: 10%; text-align:center;"><?php echo "Editar"; ?></th>
    </tr>
    <?php foreach ($agregados as $agregado): ?>
    <tr>
        <td style="width: 20%;"><?php echo $agregado['Agregado']['codigo']; ?> </td>
        <td style="width: 40%;"><?php echo $agregado['Agregado']['descripcion']; ?> </td>
        <td style="width: 10%; text-align:center;"><?php echo $options[$agregado['Agregado']['tipo']]; ?> </td>
        <td style="width: 10%; text-align:center;"><?php echo ($agregado['Agregado']['stock']==1? 'X' : ''); ?> </td>
        <td style="width: 10%; text-align:center;"><?php echo ($agregado['Agregado']['activo']==1? 'X' : ''); ?> </td>
        <td style="width: 10%; text-align:center;"><?php echo $this->Html->link($editar_img, '/agregados/editar/'.$agregado['Agregado']['id'], array('escape' => false)); ?> </td>
        
    </tr>    
    <?php endforeach; ?>    
</table>

<!--- PAGINADO ------>
<table>
    <tr>
        <td style="width: 10%; <?php echo $tabla_orga_td;?>"><?php  echo $this->Paginator->prev(!$this->Paginator->hasPrev() ? null : $prev_img, array('escape' => false), !$this->Paginator->hasPrev() ? $prev_img_disabled : null, array('class'=>'prev disabled','escape' => false));?></td>
        <td style="width: 10%; <?php echo $tabla_orga_td;?>"><?php  echo $this->Paginator->next(!$this->Paginator->hasNext() ? null : $next_img, array('escape' => false), !$this->Paginator->hasNext() ? $next_img_disabled : null, array('class'=>'next disabled','escape' => false));?></td>
        <td style="width: 80%; <?php echo $tabla_orga_td;?>"></td>
    </tr>
</table>

<!--- BOTONERA ------->
<table>
    <tr>
        <td style="width: 10%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Volver'; ?></td>
        <td style="width: 10%; text-align:left; <?php echo $tabla_orga_td;?>"><?php echo $this->Html->link($volver_img, array("controller"=>"mainmenus", "action"=>"index"), array('class' => 'button', 'title' => 'Volver', 'escape' => false));?></td>
        <td style="width: 60%; <?php echo $tabla_orga_td;?>"></td>
        <td style="width: 10%; text-align:right; <?php echo $tabla_orga_td;?>"><?php echo 'Nuevo'; ?></td>
        <td style="width: 10%; text-align:left; <?php echo $tabla_orga_td;?>"><?php echo $this->Html->link($nuevo_img, array("controller"=>"agregados", "action"=>"nuevo"), array('class' => 'button', 'title' => 'Nuevo', 'escape' => false));?></td>
    </tr>
</table>

<!-- overlayed element -->
<div id="dialogModal">
     <!-- the external content is loaded inside this tag -->
     <div class="contentWrap"></div>
</div>

<!--- FIN MARCO DE LA PANTALLA ------>
</td></tr></table>